<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教务系统</title>
    <link rel="stylesheet" href="/css/common.css">
    <link rel="stylesheet" href="/css/student.css">
    <script src="/js/jquery-1.9.1.min.js"></script>

</head>
<body>
    <div class="container">
        <div class="content">
            <div class="header clearfix">
                <div class="bottom fr">
                    <a id="emit" href="javascript:;">编辑</a>
                    <a id="keep" href="javascript:;">保存</a>
                </div>
            </div>
            <form id="form1" action="/admin/student/update"method="post">
            <div class="main">
                <!--基础信息-->
                <div class="BasicInformation">
                    <div class="title">
                        基础信息
                    </div>
                </div>
                <div class="content clearfix">
                    <div class="left fl">
                        <div>
                            <label for="">姓名：</label>
                            <input id="username"  name="username" type="text" value="${sss.username!}" disabled />
                        </div>
                        <div>
                            <label for="">性别：</label>
                            <input id="sex" name="sex" type="text" value="${sss.sex!}" disabled>
                        </div>

                        <div>
                            <label for="">出生日期：</label>
                            <input id="birthday" name="birthday" type="date" value="${sss.birthday?string('yyyy-MM-dd')}" disabled>
                        </div>


                        <div>
                            <label for="">身份证号：</label>
                            <input id="idc_code"   name="idc_code" type="text" value="${sss.idcCode!}" disabled>
                        </div>
                    </div>
                    <div class="right fr">
                        <div>
                            <label for="">籍贯</label>
                            <input id="site" name="site" class="id oInp" type="text" value="${sss.site!}" disabled>
                        </div>
                        <div>
                            <label for="">现住址</label>
                            <input id="address" name="address" class="id oInp" type="text" value="${sss.address!}" disabled>
                        </div>

                    </div>
                </div>
                <!--联系方式-->
                <div class="BasicInformation">
                    <div class="title">联系方式</div>
                </div>
                <div class="content clearfix">
                    <div class="left fl">
                        <div>
                            <label for="">手机号码：</label>
                            <input id="phone" name="phone" type="number" value="${sss.phone!}" disabled>
                        </div>
                        <div>
                            <label for="">QQ号码：</label>
                            <input id="qq" type="number" name="qq" value="${sss.qq!}" disabled>
                        </div>
                        <div>
                            <label for="">微信</label>
                            <input id="wx" type="text" name="wx" value="${sss.wx!}" disabled>
                        </div>
                    </div>
                    <div class="right fr">
                        <div>
                            <label for="">电子邮箱：</label>
                            <input id="email" name="email" type="text" value="${sss.email!}" class="mailbox" disabled>
                        </div>
                    </div>
                </div>
                <div class="BasicInformation">
                    <div class="title">
                        其他信息
                    </div>
                </div>
                <div class="content clearfix">
                    <div class="left fl">
                        <div>
                            <label   for="">学历毕业院校名称：</label>
                            <input id="college_name" name="college_name" type="text" value="${sss.collegeName!}" disabled>
                        </div>
                        <div>
                            <label   for="">学历毕业日期：</label>
                            <input id="graduate_date" name="graduate_date" type="date" value="${sss.graduateDate!?string('yyyy-MM-dd')}" disabled>
                        </div>
                        <div>
                            <label   for="">来校日期：</label>
                            <input id="join_date" name="join_date" type="date" value="${sss.joinDate!?string('yyyy-MM-dd')}" disabled>
                        </div>

                    </div>
                    <div class="right fr">
                        <div>
                            <label for="">学生家长信息：</label>
                            <input id="parent_info" name="parent_info" type="text" value="${sss.parentInfo!}" disabled>
                        </div>

                    </div>
                </div>
            </div>
            </form>
        </div>
    </div>
    <script>
        $('#politics i').on('click', function() {
            $(this).siblings('ul').show();
        });
        $('#politics ul li').on('click', function() {
            var selTxt = $(this).text();
            $('#politics a').text(selTxt);
            $('#politics ul').hide();
        });
        $('#child i').on('click', function() {
            $(this).siblings('ul').show();
        });
        $('#child ul li').on('click', function() {
            var selTxt = $(this).text();
            $('#child a').text(selTxt);
            $('#child ul').hide();
        });
        $('#emit').on('click',function(){
			$('input').removeAttr('disabled');
		});
		$('#keep').on('click',function(){


            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/admin/student/update" ,//url
                data: $('#form1').serialize(),
                success: function (result) {
                    if (result.code == 100) {
                        alert("保存成功了  亲-.-");
                    }
                    ;
                },
            });
            $('input').attr('disabled','disabled');
		});
    	$(document).ready(function(){
    		$.ajax({
	    		url: "/admin/student",
	    		type: 'post',
	    		data: {

	    		},
	    	}).then(function(res){
	    		console.log(res)
	//      		var stu_name = $('#stu_name').val();
	    			$('#username').attr('value',res.username);
	    			$('#sex').attr('value',res.sex);
	    			$('#birthday').attr('value',res.birthday);
	    			$('#idc_code').attr('value',res.idc_code);
	    			$('#site').attr('value',res.site);
	    			$('#address').attr('value',res.address);
	    			$('#qq').attr('value',res.qq);
	    			$('#phone').attr('value',res.phone);
	    			$('#email').attr('value',res.email);
	    			$('#college_name').text(res.college_name);
                    $('#graduate_date').text(res.graduate_date);
                    $('#join_date').text(res.join_date);
                    $('#parent_info').text(res.parent_info);
	    	},function(){
	    		console.log('error');
	    	});
    	});
    </script>

</body>
</html>
